<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
  const xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState === 4 && this.status === 200) {
      showResult(xhttp.responseXML);
    }
  };
  xhttp.open("GET", "books.xml", true);
  xhttp.send();

  function showResult(xml) {
    let txt = "";
    const path = "//title"
    if (xml.evaluate) {
      const nodes = xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
      let result = nodes.iterateNext();
      while (result) {
        txt += result.childNodes[0].nodeValue + "<br>";
        result = nodes.iterateNext();
      }
    }
    document.getElementById("demo").innerHTML = txt;
  }
</script>

</body>
</html>
